﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;

namespace Marbles.Core.Content.CDN
{
    public class CDNSetting
    {
        public string Name { get { return _name; } }
        public string Url { get { return _url; } set { _url = value; } }
        public string Type { get { return _type; } set { _type = value; } }
        public bool DefaultCDN { get { return _default; } set { _default = value; } }
        public string Id { get { return _id; } }

        private string _id = string.Empty;
        private string _url = string.Empty;
        private bool _default = false;
        private string _name = string.Empty;
        private string _type = string.Empty;

        public CDNSetting()
        {
            _type = string.Empty;
            _id = string.Empty;
            _url = string.Empty;
            _default = false;
            _name = string.Empty;
        }
       
        internal CDNSetting(XmlNode node)
        {
            _name = node.ParentNode.Attributes["name"].Value;
            _url = node.Attributes["url"].Value;
            _id = node.Attributes["id"].Value;
            _type = node.Attributes["type"].Value;
            _default = Convert.ToBoolean(node.Attributes["default"].Value);
        }

        public static CDNSetting Create(string Name)
        {
            CDNSetting value = new CDNSetting();
            value._name = Name;
            value._id = Guid.NewGuid().ToString();
            return value;
        }

        
    }
}